import request from '@/utils/request';
import { PageResponse } from '@/interface/pages';

/**
 * 获取分页列表
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const getCapitalList = (params: API.userCapital.PageListDto) => {
  return request<PageResponse<API.userCapital.EntitySchema[]>>({
    url: '/admin/capital',
    method: 'get',
    params
  });
};

/**
 * 详情
 *
 * @param id
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const getCapitalDetail = (id: number) => {
  return request({
    url: `/admin/capital/${id}`,
    method: 'get'
  });
};

/**
 * 编辑
 *
 * @param id
 * @param data
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const updateCapital = (id: number, data: API.userCapital.EntityDto) => {
  return request({
    url: `/admin/capital/${id}`,
    method: 'put',
    data
  });
};

/**
 * 提现错误日志
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const getCapitalError = () => {
  return request({
    url: `/wx/capital/error`,
    method: 'get'
  });
};
